package com.inhim.pjhim.adapter;

import android.content.Context;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseViewHolder;
import com.chaychan.adapter.MultipleItemRvAdapter;
import com.inhim.pjhim.adapter.provider.ReaderItemProvider;
import com.inhim.pjhim.adapter.provider.ReaderListProvider;
import com.inhim.pjhim.adapter.provider.ReaderTagItemProvider;
import com.inhim.pjhim.adapter.provider.ReaderTagItemTwoProvider;
import com.inhim.pjhim.entity.ReaderList;
import com.inhim.pjhim.entity.ReaderTwo;
import com.inhim.pjhim.entity.TagReaderList;

import java.util.List;

/**
 * Created by jianghejie on 15/11/26.
 */
public class TagReaderListAdapter<T> extends MultipleItemRvAdapter<T, BaseViewHolder> {
    public static final int READER = 100;
    public static final int READER_TWO = 300;
    public static final int READER_TYPE = 200;
    public static final int READER_LIST = 400;
    private Context context;
    private String TAG;
    public TagReaderListAdapter(@Nullable List<T> data, Context context) {
        super(data);
        this.context = context;
        finishInitialize();//调用该方法告知MultipleItemRvAdapter1已初始化完构造函数参数的传递
    }

    @Override
    protected int getViewType(T news) {
        //纪录隐藏最后一个课程数据item的横线
        /*if(news instanceof ReaderList.List){
            size++;
            Log.e("position11",size+"");
        }else{
            size=0;
        }*/
        if (news instanceof ReaderTwo) {
            return READER_TWO;
        }else if (news instanceof TagReaderList.Reader) {
            return READER;
        }else if (news instanceof TagReaderList.ReaderType) {
            return READER_TYPE;
        } else if(news instanceof ReaderList.List){
            return READER_LIST;
        }else {
            return 0;
        }
    }

    @Override
    public void registerItemProvider() {
        //注册itemProvider
        mProviderDelegate.registerProvider(new ReaderItemProvider(context));
        mProviderDelegate.registerProvider(new ReaderTagItemProvider(context));
        mProviderDelegate.registerProvider(new ReaderTagItemTwoProvider(context));
        mProviderDelegate.registerProvider(new ReaderListProvider(context));
    }
}





















